<template>
	<view class="goods_detail">
		<swiper indicator-dots="true" autoplay="true">
			<swiper-item v-for="item in slideshows" :key="item.id">
				<image :src="qiniu_domain+item.img_url"></image>
			</swiper-item>
			<!-- <swiper-item>
				<image src="../../static/imgs/dog.jpg"></image>
			</swiper-item>
			<swiper-item>
				<image src="../../static/imgs/cat.jpg"></image>
			</swiper-item> -->
		</swiper>
		<view class="goods_info">
			<view class="price">
				<text>￥998</text>
			</view>
			<view class="goods_name_total">
			<view class="goods_name">伸腿瞪眼丸</view>
			<view class="sales_total">销量：999</view>
			</view>
		</view>
		<view class="line"></view>
		<view class="line"></view>
		<view class="goods_intro">
			<view class="tit">商品详情介绍</view>
			<view class="content">
				<rich-text :nodes="content"></rich-text>
			</view>
		</view>
		<view class="goods_nav">
			<uni-goods-nav :fill="true"  :options="options" :button-group="buttonGroup"  @click="onClick" @buttonClick="buttonClick" ></uni-goods-nav>
		</view>
	</view>
</template>

<script>
	import uniGoodsNav from '@/components/uni-goods-nav/uni-goods-nav.vue'
	export default {
		data() {
			return {
				host:getApp().globalData.host,
				qiniu_domain:getApp().globalData.qiniu_domain,
				id: 0,
				slideshows: [],
				info: {},
				content: '<p>警告</p><p>真香警告</p><p>真真香警告</p><p>真真真香警告</p><p>真真真真香警告</p><p>警告</p>',
				options: [
					{
						icon: 'https://img-cdn-qiniu.dcloud.net.cn/uniapp/uni-ui/goodsnav/carts.png',
						text: '购物车',
						info: 0
					}
				],
				buttonGroup: [
					{
						text: '加入购物车',
						backgroundColor: '#ff0000',
						color: '#fff'
					},
					{
						text: '立即购买',
						backgroundColor: '#ffa200',
						color: '#fff'
					}
				]
			}
		},
		methods: {
			async getSwipers () {
				await uni.request({
					url:this.host+"/api/slide",
					success: (res) => {
						// console.log(res.data)
						if (res.data.data.code == 0){
							return uni.showToast({
								title:"获取数据失败"
							})
						}
						this.slideshows = res.data.data.slides
					}
				})
			},
			// async getDetailInfo () {
			// 	const res = await this.$myRuquest({
			// 		url: '/api/goods/getinfo/'+this.id
			// 	})
			// 	this.info = res.data.message[0]
			// },
			// async getDetailContent () {
			// 	const res = await this.$myRuquest({
			// 		url: '/api/goods/getdesc/'+this.id
			// 	})
			// 	this.content = res.data.message[0].content
			// },
			onClick (e) {
				// uni.showToast({
				// 	title: `点击${e.content.text}`,
				// 	icon: 'none'
				// })
				console.log(e)
			},
			buttonClick (e) {
				console.log(e)
				// this.options[2].info++
			}
		},
		
		onLoad (options) {
			this.id = options.id
			this.getSwipers()
			// this.getDetailInfo()
			// this.getDetailContent()
		},
		components: {uniGoodsNav}
	}
</script>

<style lang="scss">
.goods_detail{
	box-sizing: border-box;
	swiper{
		height: 700rpx;
		image{
			width: 100%;
			height: 100%;
		}
	}
	.goods_info {
		padding:5rpx 35rpx 5rpx 20rpx;
		.price {
			font-size: 30rpx;
			color: #FF6A6A;
			line-height: 50rpx;
		}
		.goods_name_total{
			display: flex;
			justify-content: space-between;
			.goods_name{
				font-size: 28rpx;
				line-height: 50rpx;
			}
			.sales_total{
				font-size: 26rpx;
				line-height: 50rpx;
			}
		}
		
	}
	// .box2 {
	// 	padding: 0 10px;
	// 	font-size: 32rpx;
	// 	line-height: 70rpx;
	// }
	.goods_intro {
		padding-bottom: 50px;
		.tit{
			font-size: 28rpx;
			padding-left: 10px;
			border-bottom: 1px solid #eee;
			line-height: 60rpx;
		}
		.content {
			padding: 8rpx 20rpx;
			font-size: 27rpx;
			color: #333;
			line-height: 50rpx;
		}
	}
}

.goods_nav {
	position: fixed;
	bottom:0;
	width: 100%;
}

.line {
	height: 6rpx;
	width: 750rpx;
	background: #eee;
}
</style>
